home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #6 / Amiga Plus CD - 1996 - No. 06.iso / pd / programmierung / proasm / routines / intuitionlib.r < prev    next >
Text File  |  1980-01-25  |  3KB  |  130 lines

  1.  
  2. ;---;  intuitionlib.r  ;-------------------------------------------------------
  3. *
  4. *    ****    INTUITION LIBRARY OPEN AND CLOSE    ****
  5. *
  6. *    Author        Stefan Walter
  7. *    Version        1.00
  8. *    Last Revision    21.07.92
  9. *    Identifier    ilb_defined
  10. *       Prefix        ilb_    (intuition library)
  11. *                 ¯         ¯ ¯
  12. *    Functions    OpenIntuitionLib, GetIntuitionBase, CloseIntuitionLib
  13. *
  14. ;------------------------------------------------------------------------------
  15.  
  16. ;------------------
  17.     ifnd    ilb_defined
  18. ilb_defined    =0
  19.  
  20. ;------------------
  21. ilb_oldbase    equ __base
  22.     base    ilb_base
  23. ilb_base:
  24.  
  25. ;------------------
  26.  
  27. ;------------------------------------------------------------------------------
  28. *
  29. * OpenIntuitionLib    Open intuition.library once and use a nesting counter.
  30. *
  31. * RESULT:    d0    IntuitionBase.
  32. *        a6    also.
  33. *        ccr    On d0.
  34. ;
  35. ;------------------------------------------------------------------------------
  36.  
  37. ;------------------
  38. OpenIntuitionLib:
  39.  
  40. ;------------------
  41. ; Open only if ilb_nestcnt=0.
  42. ;
  43. \open:
  44.     movem.l    d1-a5,-(sp)
  45.     lea    ilb_base(pc),a4
  46.     move.l    ilb_nestcnt(pc),d0
  47.     bne.s    \isopen
  48.     move.l    4.w,a6
  49.     lea    ilb_name(pc),a1
  50.     jsr    -408(a6)        ;OldOpenLibrary()
  51.     move.l    d0,ilb_intbase(a4)
  52. \isopen:
  53.     addq.l    #1,ilb_nestcnt(a4)
  54.     move.l    ilb_intbase(pc),d0
  55.     move.l    d0,a6
  56.     movem.l    (sp)+,d1-a5
  57.     rts
  58.  
  59. ;------------------
  60.  
  61. ;------------------------------------------------------------------------------
  62. *
  63. * GetIntuitionBase    Get intuitionbase in a6.
  64. *
  65. * RESULT:    a6    intuitionbase
  66. *
  67. ;------------------------------------------------------------------------------
  68.  
  69. ;------------------
  70. GetIntuitionBase:
  71.  
  72. ;------------------
  73. ; Intuitionbase => a6.
  74. ;
  75. \getbase:
  76.     move.l    ilb_intbase(pc),a6
  77.     rts
  78.  
  79. ;------------------
  80.  
  81. ;------------------------------------------------------------------------------
  82. *
  83. * CloseIntuitionLib    Close intuition.library if ilb_nestcnt gets zero.
  84. *
  85. ;------------------------------------------------------------------------------
  86.  
  87. ;------------------
  88. CloseIntuitionLib:
  89.  
  90. ;------------------
  91. ; Decrease dlb_nestcnt and close library if finished.
  92. ;
  93. \close:
  94.     movem.l    d0-a6,-(sp)
  95.     lea    ilb_nestcnt(pc),a4
  96.     subq.l    #1,(a4)
  97.     bhi.s    \end
  98.     move.l    ilb_intbase(pc),a1
  99.     move.l    a1,d0
  100.     beq.s    \end
  101.     move.l    4.w,a6
  102.     jsr    -414(a6)        ;CloseLibrary()
  103. \end:
  104.     movem.l    (sp)+,d0-a6
  105.     rts
  106.  
  107. ;------------------
  108.  
  109. ;--------------------------------------------------------------------
  110.  
  111. ;------------------
  112. ; Data for library handling.
  113. ;
  114. ilb_name:    dc.b    "intuition.library",0
  115. ilb_intbase:    dc.l    0
  116. ilb_nestcnt:    dc.l    0
  117.  
  118. ;------------------
  119.  
  120. ;--------------------------------------------------------------------
  121.  
  122. ;------------------
  123.     base    ilb_oldbase
  124.  
  125. ;------------------
  126.     endif
  127.  
  128.  end
  129.  
  130.